<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('临期工单T')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="myTwfNO"/>
                        </li>
                        <li>
                            派发单位：<input type="text" name="sdeptName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
<!--            <a class="btn btn-success single disabled" onclick="reply()">-->
<!--                <i class="fa"></i> 回复-->
<!--            </a>-->
<!--            <a class="btn btn-primary single disabled" onclick="postpone()">-->
<!--                <i class="fa"></i> 延期-->
<!--            </a>-->
<!--            <a class="btn btn-danger multiple disabled" onclick="Return()">-->
<!--                <i class="fa"></i> 退回-->
<!--            </a>-->
            <a class="btn btn-success multiple disabled" onclick="detail('')">
                <i class="fa"></i> 查看
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/common/js/common.js}"></script>
<script th:src="@{/js/telReport.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "system/report/tel";
    var mInterior = ctx + "system/mInterior";
    $(function () {
        var options = {
            url: prefix+"/muBlueSJson",
            sortName: "pkId",
            sortOrder: "desc",
            updateUrl: prefix + "/cmnFile/dlReplyS",
            uniqueId: "myPkVal",
            modalName: "临期工单T",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            rowStyle: rowStyle,
            columns: [{
                checkbox: true
            },
                {field: 'myPkVal', title: 'pkId', hidden: true, visible: false},
                {field: 'wfId', title: 'wfId', hidden: true, visible: false},
                {field: 'fmDept', title: 'fmDept', hidden: true, visible: false},
                {field: 'OriLevel', title: 'OriLevel', hidden: true, visible: false},
                {field: 'sbDept', title: 'sbDept', hidden: true, visible: false},
                {field: 'myTwfNO', title: '工单编号', align: 'center', sortable: true},
                {field: 'myTwfTopic', title: '工单主题', align: 'center', sortable: true},
                {field: 'SeqName', title: '交办次序', align: 'center'},
                {field: 'SortName', title: '性质', align: 'center', sortable: true},
                {field: 'DealName', title: '办理方式', align: 'center', hidden: true},
                {field: 'bkLimit', title: '办理期限', align: 'center', sortable: true, width: 80},
                {field: 'SDeptName', title: '来自',align: 'center', hidden: true},
                {field: 'acDate', title: '签收日期', align: 'center', sortable: true, width: 80},
                {field: 'bkState', title: '标记', align: 'center', sortable: true,formatter:function(value,row,index){return fmtSBBackState(value,row,index);}},
                {field: 'acRemark', title: '备注', align: 'center',  width: 80},
                {field: 'backDesc', title: '下级回复', align: 'center' , sortable: true
                    // formatter:function(value,row,index){return fmtBackState(value,row,index);}
                },
                {field: 'backTime', title: '回复时间', align: 'center', sortable: true, width: 80},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="detail('+row.WfId+')"><i class="fa"></i>查看</a>');
                        // actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="reply('+row.WfId+','+row.myPkVal+')"><i class="fa"></i>回复</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function postpone(){
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        var wfId = row[0].WfId;
        var sendId = row[0].myPkVal;
        if (wfId && sendId) {
            var url = mInterior + "/cmnFile/tDeferList?wfId="+wfId+"&sendId="+sendId;
            $.modal.openTab('延期申请情况',url);
        }
    }

    function reply(wfId,sendId){
        if (!(wfId && sendId)) {
            let row = $("#bootstrap-table").bootstrapTable('getSelections');
            var wfId = row[0].WfId;
            var sendId = row[0].myPkVal;
        }
        var url = prefix + "/cmnFile/dlReplyS?wfId="+wfId+"&sendId="+sendId;
        $.modal.openTab('回复电话工单',url);
    }

    function Return(){
        if (!(wfId && sendId)) {
            let row = $("#bootstrap-table").bootstrapTable('getSelections');
            var wfId = row[0].WfId;
            var sendId = row[0].myPkVal;
        }
        var url = prefix + "/cmnFile/dlBackS?wfId="+wfId+"&sendId="+sendId;
        $.modal.openTab('退回电话工单',url);
    }

    function fmtBackState(value,row,index) {
        var wfid = row.wfId;
        var fmunit = row.sbDept;
        var str = '';
        $.ajax({
            type: 'post',
            data: {wfId: wfid, fmunit: fmunit},
            dataType: 'json',
            async: false,
            url: ctx + '/mMailWF/forShow/updateState',
            success: function (result) {
                str = result.backDesc;
            }
        });
        return str;
    }
</script>
</body>
</html>